package frsf.cidisi.exercise.arqueologic.situationCalculus.actions;

import frsf.cidisi.exercise.arqueologic.situationCalculus.ArqueologicAgentPerception;
import frsf.cidisi.exercise.arqueologic.situationCalculus.ArqueologicEnvironmentState;
import frsf.cidisi.exercise.arqueologic.situationCalculus.ArqueologicState;
import frsf.cidisi.faia.agent.situationcalculus.SituationCalculusAction;
import frsf.cidisi.faia.state.AgentState;
import frsf.cidisi.faia.state.EnvironmentState;

public class RecogerCofre extends SituationCalculusAction {

    @Override
    public EnvironmentState execute(AgentState ast, EnvironmentState est) {
    	ArqueologicEnvironmentState environmentState = (ArqueologicEnvironmentState) est;
        ArqueologicState agState = ((ArqueologicState) ast);    
        // TODO: Complete Method
        /*if (agState.getPercepcionCofre() == ArqueologicAgentPerception.COFRE_LLENO ) {
        	if(agState.getmundo().getCofre(agState.getPosicion()).getPeso() <= agState.getCapacidadRestante()){
        	System.out.println("Decidio recoger en "+agState.getPosicion());
        	agState.agregarCofre(agState.getmundo().getCofre(agState.getPosicion()));
        	agState.setCapacidadRestante(agState.getCapacidadRestante() - agState.getmundo().getCofre(agState.getPosicion()).getPeso());
        	agState.getmundo().restarTesoro(agState.getPosicion());
        	environmentState.getmundo().getAldea(agState.getPosicion()).llevarCofre();
        	agState.getmundo().getAldea(agState.getPosicion()).llevarCofre();
        	agState.setPercepcionCofre(ArqueologicAgentPerception.COFRE_VACIO);
        	return environmentState;
        	}
        }else{
        	System.out.println("Oh, ah pasado el pirata Gaston!!");
        		agState.setPosicion(agState.ultimaAldeaVisitada());
        		environmentState.setposicionArqueologo(agState.ultimaAldeaVisitada());
        		agState.quitarUltimaAldeaVisitada();
        		
        		return environmentState;
        }*/

        return environmentState;
    }

    @Override
    public String toString() {
        return "RecogerCofre";
    }
}

